{% extends 'layout/base.html' %}

{% block content %}
<div class="row mt-5">
    <div class="col-lg-3">
        {% set active_nav = 'users' %}
        {% include 'config/includes/sidebar.html' %}
    </div>
    <div class="col-lg">
        <h4>Users</h4>

        <div class="clearfix pb-3">
            <div class="float-right">
                <a href="{{ url_for('config.user_edit', user_id=0) }}" class="btn btn-primary"><i class="fas fa-user-plus"></i> <span class="ml-1">new user</span></a>
            </div>
        </div>

        <table class="table table-striped table-responsive-lg">
            <thead>
            <tr>
                <th>ID</th>
                <th>Username</th>
                <th>Full Name</th>
                <th>E-mail</th>
                <th>Auth</th>
                <th class="text-center">Admin</th>
                <th class="text-center">Active</th>
                <th class="text-center">2FA</th>
                <th></th>
            </tr>
            </thead>
            <tbody>
            {% for user in users %}
            <tr>
                <td>{{ user.id }}</td>
                <td>{{ user.username }}</td>
                <td>{{ user.full_name }}</td>
                <td>{{ user.email }}</td>
                <td>{{ auth_types[user.auth_type_id] }}</td>
                <td class="text-center">
                    {% set class = 'success' if user.admin else 'danger' %}
                    {% set icon = 'check' if user.admin else 'times' %}
                    <span class="text-{{ class }}"><i class="fas fa-{{ icon }} fa-fw"></i></span>
                </td>
                <td class="text-center">
                    {% set class = 'success' if user.active else 'danger' %}
                    {% set icon = 'check' if user.active else 'times' %}
                    <span class="text-{{ class }}"><i class="fas fa-{{ icon }} fa-fw"></i></span>
                </td>
                <td class="text-center">
                    {% set class = 'success' if user.has_2fa() else 'danger' %}
                    {% set icon = 'check' if user.has_2fa() else 'times' %}
                    <span class="text-{{ class }}"><i class="fas fa-{{ icon }} fa-fw"></i></span>
                </td>
                <td class="text-right">
                    <a href="{{ url_for('config.user_edit', user_id=user.id) }}"><i class="fas fa-edit"></i></a>
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}